<%@ page import="com.goal98.grails.plugin.account.domain.Transaction; com.goal98.grails.plugin.account.domain.Debit" %>
<div class="dialog">
  <div class="list">
    <table>
      <thead>
        <tr>

          <g:sortableColumn property="description" title="${message(code:'transaction.desc', 'default':'Description')}"/>

          <g:sortableColumn property="amount" title="${message(code:'transaction.amount', 'default':'Amount')}" width="20px"/>

          <g:sortableColumn property="dateCreated" title="${message(code:'transaction.date', 'default':'Date Created')}"/>

        </tr>
      </thead>
      <tbody>
        <g:each in="${Transaction.findAllByAccount(account, [max:20, sort:'dateCreated', order:'asc'])}" status="i" var="transactionInstance">
          <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">

            <td>${fieldValue(bean: transactionInstance, field: 'description')}</td>

            <td style="color:${(transactionInstance instanceof Debit) ? 'red' : 'green'};">${fieldValue(bean: transactionInstance, field: 'amount')}</td>

            <td>${fieldValue(bean: transactionInstance, field: 'dateCreated')}</td>

          </tr>
        </g:each>
      </tbody>
    </table>
  </div>
  <table>
    <tbody>
      <tr class="prop">
        <td valign="top" class="name"><g:message code="account.balance" default="Balance"/>:</td>
        <td valign="top" class="value">
          <div class="highlight">
            <div id="updateMe">${account?.balance}</div>
          </div>
        </td>
      </tr>
    </tbody>
  </table>
</div>